SlideShare a Scribd company logo
1 of 47
Class No.12  Data Structures http://ecomputernotes.com
Operations on Binary Tree ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Operations on Binary Tree ,[object Object],[object Object],[object Object],http://ecomputernotes.com
Applications of Binary Trees ,[object Object],[object Object],http://ecomputernotes.com
Applications of Binary Trees ,[object Object],14, 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14, 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 http://ecomputernotes.com
Searching for Duplicates ,[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Searching for Duplicates ,[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
Searching for Duplicates ,[object Object],[object Object],[object Object],http://ecomputernotes.com
Searching for Duplicates 14, 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 http://ecomputernotes.com
Searching for Duplicates 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 http://ecomputernotes.com
Searching for Duplicates 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 http://ecomputernotes.com
Searching for Duplicates 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 http://ecomputernotes.com
Searching for Duplicates 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 http://ecomputernotes.com
Searching for Duplicates 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 http://ecomputernotes.com
Searching for Duplicates 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 http://ecomputernotes.com
Searching for Duplicates 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 http://ecomputernotes.com
Searching for Duplicates 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 http://ecomputernotes.com
Searching for Duplicates 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 http://ecomputernotes.com
Searching for Duplicates 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 http://ecomputernotes.com
Searching for Duplicates 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 http://ecomputernotes.com
Searching for Duplicates 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 http://ecomputernotes.com
Searching for Duplicates 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 http://ecomputernotes.com
Searching for Duplicates 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 http://ecomputernotes.com
Searching for Duplicates 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 http://ecomputernotes.com
Searching for Duplicates 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 http://ecomputernotes.com
Searching for Duplicates 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 4 http://ecomputernotes.com
Searching for Duplicates 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 http://ecomputernotes.com
Searching for Duplicates 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 http://ecomputernotes.com
Searching for Duplicates 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
Searching for Duplicates 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
Searching for Duplicates 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
C++ Implementation #include <stdlib.h> template <class Object> class TreeNode {  public: // constructors TreeNode()  { this->object = NULL;  this->left = this->right = NULL; }; TreeNode( Object* object )  {  this->object = object;  this->left = this->right = NULL; }; http://ecomputernotes.com
C++ Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
C++ Implementation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://ecomputernotes.com
C++ Implementation private: Object* object; TreeNode* left; TreeNode* right;  }; // end class TreeNode http://ecomputernotes.com
C++ Implementation #include <iostream> #include <stdlib.h> #include &quot;TreeNode.cpp&quot; int main(int argc, char *argv[]) { int x[] = { 14, 15, 4, 9, 7, 18, 3, 5, 16,4, 20, 17,  9, 14,5, -1}; TreeNode<int>* root = new TreeNode<int>(); root->setInfo( &x[0] ); for(int i=1; x[i] > 0; i++ ) { insert(root, &x[i] ); } } http://ecomputernotes.com
C++ Implementation void insert(TreeNode<int>* root, int* info) { TreeNode<int>* node = new TreeNode<int>(info); TreeNode<int> *p, *q; p = q = root; while( *info != *(p->getInfo()) && q != NULL ) { p = q; if( *info < *(p->getInfo()) ) q = p->getLeft(); else q = p->getRight(); } http://ecomputernotes.com
C++ Implementation if( *info == *(p->getInfo()) ){ cout << &quot;attempt to insert duplicate: &quot;  << *info << endl; delete node; } else if( *info < *(p->getInfo()) ) p->setLeft( node ); else p->setRight( node );  } // end of insert http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p p->setRight( node ); node http://ecomputernotes.com

More Related Content

Viewers also liked

computer notes - Data Structures - 29
computer notes - Data Structures - 29computer notes - Data Structures - 29
computer notes - Data Structures - 29
ecomputernotes
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22
ecomputernotes
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28
ecomputernotes
 
computer notes - Data Structures - 27
computer notes - Data Structures - 27computer notes - Data Structures - 27
computer notes - Data Structures - 27
ecomputernotes
 
computer notes - Data Structures - 18
computer notes - Data Structures - 18computer notes - Data Structures - 18
computer notes - Data Structures - 18
ecomputernotes
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1
ecomputernotes
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
ecomputernotes
 
computer notes - Data Structures - 37
computer notes - Data Structures - 37computer notes - Data Structures - 37
computer notes - Data Structures - 37
ecomputernotes
 
computer notes - Data Structures - 21
computer notes - Data Structures - 21computer notes - Data Structures - 21
computer notes - Data Structures - 21
ecomputernotes
 
computer notes - Data Structures - 6
computer notes - Data Structures - 6computer notes - Data Structures - 6
computer notes - Data Structures - 6
ecomputernotes
 
computer notes - Data Structures - 5
computer notes - Data Structures - 5computer notes - Data Structures - 5
computer notes - Data Structures - 5
ecomputernotes
 
computer notes - Data Structures - 7
computer notes - Data Structures - 7computer notes - Data Structures - 7
computer notes - Data Structures - 7
ecomputernotes
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
ecomputernotes
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
ecomputernotes
 
computer notes - Data Structures - 23
computer notes - Data Structures - 23computer notes - Data Structures - 23
computer notes - Data Structures - 23
ecomputernotes
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16
ecomputernotes
 
computer notes - Data Structures - 24
computer notes - Data Structures - 24computer notes - Data Structures - 24
computer notes - Data Structures - 24
ecomputernotes
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
ecomputernotes
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8
ecomputernotes
 

Viewers also liked (20)

computer notes - Data Structures - 29
computer notes - Data Structures - 29computer notes - Data Structures - 29
computer notes - Data Structures - 29
 
computer notes - Data Structures - 22
computer notes - Data Structures - 22computer notes - Data Structures - 22
computer notes - Data Structures - 22
 
computer notes - Data Structures - 28
computer notes - Data Structures - 28computer notes - Data Structures - 28
computer notes - Data Structures - 28
 
computer notes - Data Structures - 27
computer notes - Data Structures - 27computer notes - Data Structures - 27
computer notes - Data Structures - 27
 
computer notes - Data Structures - 18
computer notes - Data Structures - 18computer notes - Data Structures - 18
computer notes - Data Structures - 18
 
computer notes - Data Structures - 1
computer notes - Data Structures - 1computer notes - Data Structures - 1
computer notes - Data Structures - 1
 
computer notes - Data Structures - 36
computer notes - Data Structures - 36computer notes - Data Structures - 36
computer notes - Data Structures - 36
 
computer notes - Data Structures - 37
computer notes - Data Structures - 37computer notes - Data Structures - 37
computer notes - Data Structures - 37
 
computer notes - Data Structures - 21
computer notes - Data Structures - 21computer notes - Data Structures - 21
computer notes - Data Structures - 21
 
computer notes - Data Structures - 6
computer notes - Data Structures - 6computer notes - Data Structures - 6
computer notes - Data Structures - 6
 
computer notes - Data Structures - 5
computer notes - Data Structures - 5computer notes - Data Structures - 5
computer notes - Data Structures - 5
 
computer notes - Data Structures - 7
computer notes - Data Structures - 7computer notes - Data Structures - 7
computer notes - Data Structures - 7
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
 
computer notes - Data Structures - 3
computer notes - Data Structures - 3computer notes - Data Structures - 3
computer notes - Data Structures - 3
 
computer notes - Deleting a node
computer notes - Deleting a nodecomputer notes - Deleting a node
computer notes - Deleting a node
 
computer notes - Data Structures - 23
computer notes - Data Structures - 23computer notes - Data Structures - 23
computer notes - Data Structures - 23
 
computer notes - Data Structures - 16
computer notes - Data Structures - 16computer notes - Data Structures - 16
computer notes - Data Structures - 16
 
computer notes - Data Structures - 24
computer notes - Data Structures - 24computer notes - Data Structures - 24
computer notes - Data Structures - 24
 
computer notes - Data Structures - 11
computer notes - Data Structures - 11computer notes - Data Structures - 11
computer notes - Data Structures - 11
 
computer notes - Data Structures - 8
computer notes - Data Structures - 8computer notes - Data Structures - 8
computer notes - Data Structures - 8
 

Similar to computer notes - Data Structures - 12

computer notes - Data Structures - 14
computer notes - Data Structures - 14computer notes - Data Structures - 14
computer notes - Data Structures - 14
ecomputernotes
 
Computer notes data structures - 9
Computer notes   data structures - 9Computer notes   data structures - 9
Computer notes data structures - 9
ecomputernotes
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9
ecomputernotes
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15
ecomputernotes
 

Similar to computer notes - Data Structures - 12 (20)

computer notes - Data Structures - 14
computer notes - Data Structures - 14computer notes - Data Structures - 14
computer notes - Data Structures - 14
 
Computer notes - Recursive
Computer notes  - RecursiveComputer notes  - Recursive
Computer notes - Recursive
 
Computer notes - Mergesort
Computer notes - MergesortComputer notes - Mergesort
Computer notes - Mergesort
 
Computer notes data structures - 9
Computer notes   data structures - 9Computer notes   data structures - 9
Computer notes data structures - 9
 
computer notes - Binary tree
computer notes - Binary treecomputer notes - Binary tree
computer notes - Binary tree
 
Stop that earthquake - Plone and Pyramid to the rescue - PloneConf 2012
Stop that earthquake - Plone and Pyramid to the rescue - PloneConf 2012Stop that earthquake - Plone and Pyramid to the rescue - PloneConf 2012
Stop that earthquake - Plone and Pyramid to the rescue - PloneConf 2012
 
Old Dogs & New Tricks: What's New with Perl5 This Century
Old Dogs & New Tricks: What's New with Perl5 This CenturyOld Dogs & New Tricks: What's New with Perl5 This Century
Old Dogs & New Tricks: What's New with Perl5 This Century
 
computer notes - Data Structures - 9
computer notes - Data Structures - 9computer notes - Data Structures - 9
computer notes - Data Structures - 9
 
Continuous Delivery A dramedy (with happy-end?) in 5 scenes
Continuous Delivery A dramedy (with happy-end?) in 5 scenesContinuous Delivery A dramedy (with happy-end?) in 5 scenes
Continuous Delivery A dramedy (with happy-end?) in 5 scenes
 
Lecture10
Lecture10Lecture10
Lecture10
 
computer notes - Data Structures - 15
computer notes - Data Structures - 15computer notes - Data Structures - 15
computer notes - Data Structures - 15
 
Computer notes - Expression Tree
Computer notes - Expression TreeComputer notes - Expression Tree
Computer notes - Expression Tree
 
Computer notes - The const Keyword
Computer notes - The const KeywordComputer notes - The const Keyword
Computer notes - The const Keyword
 
CGo for fun and profit
CGo for fun and profitCGo for fun and profit
CGo for fun and profit
 
ppt
pptppt
ppt
 
Computer notes - Build Heap
Computer notes  - Build HeapComputer notes  - Build Heap
Computer notes - Build Heap
 
E Science4 Chromatin Research
E Science4 Chromatin ResearchE Science4 Chromatin Research
E Science4 Chromatin Research
 
Exploring the Sweet Spot: Geolocation, Health, and Gov-data
Exploring the Sweet Spot: Geolocation, Health, and Gov-data Exploring the Sweet Spot: Geolocation, Health, and Gov-data
Exploring the Sweet Spot: Geolocation, Health, and Gov-data
 
Computer notes - Josephus Problem
Computer notes - Josephus ProblemComputer notes - Josephus Problem
Computer notes - Josephus Problem
 
PHP - RAQ (Rarely Asked Questions!)
PHP - RAQ (Rarely Asked Questions!)PHP - RAQ (Rarely Asked Questions!)
PHP - RAQ (Rarely Asked Questions!)
 

More from ecomputernotes

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30
ecomputernotes
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraints
ecomputernotes
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functions
ecomputernotes
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueries
ecomputernotes
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objects
ecomputernotes
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19
ecomputernotes
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4
ecomputernotes
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueries
ecomputernotes
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functions
ecomputernotes
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
ecomputernotes
 
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY ClauseComputer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY Clause
ecomputernotes
 
Computer notes - Manipulating Data
Computer notes - Manipulating DataComputer notes - Manipulating Data
Computer notes - Manipulating Data
ecomputernotes
 
Computer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT StatementsComputer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT Statements
ecomputernotes
 
computer notes - Data Structures - 10
computer notes - Data Structures - 10computer notes - Data Structures - 10
computer notes - Data Structures - 10
ecomputernotes
 
Computer notes - Controlling User Access
Computer notes - Controlling User AccessComputer notes - Controlling User Access
Computer notes - Controlling User Access
ecomputernotes
 
Computer notes - Using SET Operator
Computer notes - Using SET OperatorComputer notes - Using SET Operator
Computer notes - Using SET Operator
ecomputernotes
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
ecomputernotes
 

More from ecomputernotes (17)

computer notes - Data Structures - 30
computer notes - Data Structures - 30computer notes - Data Structures - 30
computer notes - Data Structures - 30
 
Computer notes - Including Constraints
Computer notes - Including ConstraintsComputer notes - Including Constraints
Computer notes - Including Constraints
 
Computer notes - Date time Functions
Computer notes - Date time FunctionsComputer notes - Date time Functions
Computer notes - Date time Functions
 
Computer notes - Subqueries
Computer notes - SubqueriesComputer notes - Subqueries
Computer notes - Subqueries
 
Computer notes - Other Database Objects
Computer notes - Other Database ObjectsComputer notes - Other Database Objects
Computer notes - Other Database Objects
 
computer notes - Data Structures - 19
computer notes - Data Structures - 19computer notes - Data Structures - 19
computer notes - Data Structures - 19
 
computer notes - Data Structures - 4
computer notes - Data Structures - 4computer notes - Data Structures - 4
computer notes - Data Structures - 4
 
Computer notes - Advanced Subqueries
Computer notes -   Advanced SubqueriesComputer notes -   Advanced Subqueries
Computer notes - Advanced Subqueries
 
Computer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group FunctionsComputer notes - Aggregating Data Using Group Functions
Computer notes - Aggregating Data Using Group Functions
 
computer notes - Data Structures - 35
computer notes - Data Structures - 35computer notes - Data Structures - 35
computer notes - Data Structures - 35
 
Computer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY ClauseComputer notes - Enhancements to the GROUP BY Clause
Computer notes - Enhancements to the GROUP BY Clause
 
Computer notes - Manipulating Data
Computer notes - Manipulating DataComputer notes - Manipulating Data
Computer notes - Manipulating Data
 
Computer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT StatementsComputer notes - Writing Basic SQL SELECT Statements
Computer notes - Writing Basic SQL SELECT Statements
 
computer notes - Data Structures - 10
computer notes - Data Structures - 10computer notes - Data Structures - 10
computer notes - Data Structures - 10
 
Computer notes - Controlling User Access
Computer notes - Controlling User AccessComputer notes - Controlling User Access
Computer notes - Controlling User Access
 
Computer notes - Using SET Operator
Computer notes - Using SET OperatorComputer notes - Using SET Operator
Computer notes - Using SET Operator
 
computer notes - Data Structures - 38
computer notes - Data Structures - 38computer notes - Data Structures - 38
computer notes - Data Structures - 38
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

computer notes - Data Structures - 12

  • 1. Class No.12 Data Structures http://ecomputernotes.com
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Searching for Duplicates 14, 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 http://ecomputernotes.com
  • 10. Searching for Duplicates 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 http://ecomputernotes.com
  • 11. Searching for Duplicates 15, 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 http://ecomputernotes.com
  • 12. Searching for Duplicates 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 http://ecomputernotes.com
  • 13. Searching for Duplicates 4, 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 http://ecomputernotes.com
  • 14. Searching for Duplicates 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 http://ecomputernotes.com
  • 15. Searching for Duplicates 9, 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 http://ecomputernotes.com
  • 16. Searching for Duplicates 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 http://ecomputernotes.com
  • 17. Searching for Duplicates 7, 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 http://ecomputernotes.com
  • 18. Searching for Duplicates 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 http://ecomputernotes.com
  • 19. Searching for Duplicates 18, 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 http://ecomputernotes.com
  • 20. Searching for Duplicates 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 http://ecomputernotes.com
  • 21. Searching for Duplicates 3, 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 http://ecomputernotes.com
  • 22. Searching for Duplicates 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 http://ecomputernotes.com
  • 23. Searching for Duplicates 5, 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 http://ecomputernotes.com
  • 24. Searching for Duplicates 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 http://ecomputernotes.com
  • 25. Searching for Duplicates 16, 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 http://ecomputernotes.com
  • 26. Searching for Duplicates 4, 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 4 http://ecomputernotes.com
  • 27. Searching for Duplicates 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 http://ecomputernotes.com
  • 28. Searching for Duplicates 20, 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 http://ecomputernotes.com
  • 29. Searching for Duplicates 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
  • 30. Searching for Duplicates 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
  • 31. Searching for Duplicates 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 http://ecomputernotes.com
  • 32. C++ Implementation #include <stdlib.h> template <class Object> class TreeNode { public: // constructors TreeNode() { this->object = NULL; this->left = this->right = NULL; }; TreeNode( Object* object ) { this->object = object; this->left = this->right = NULL; }; http://ecomputernotes.com
  • 33.
  • 34.
  • 35. C++ Implementation private: Object* object; TreeNode* left; TreeNode* right; }; // end class TreeNode http://ecomputernotes.com
  • 36. C++ Implementation #include <iostream> #include <stdlib.h> #include &quot;TreeNode.cpp&quot; int main(int argc, char *argv[]) { int x[] = { 14, 15, 4, 9, 7, 18, 3, 5, 16,4, 20, 17, 9, 14,5, -1}; TreeNode<int>* root = new TreeNode<int>(); root->setInfo( &x[0] ); for(int i=1; x[i] > 0; i++ ) { insert(root, &x[i] ); } } http://ecomputernotes.com
  • 37. C++ Implementation void insert(TreeNode<int>* root, int* info) { TreeNode<int>* node = new TreeNode<int>(info); TreeNode<int> *p, *q; p = q = root; while( *info != *(p->getInfo()) && q != NULL ) { p = q; if( *info < *(p->getInfo()) ) q = p->getLeft(); else q = p->getRight(); } http://ecomputernotes.com
  • 38. C++ Implementation if( *info == *(p->getInfo()) ){ cout << &quot;attempt to insert duplicate: &quot; << *info << endl; delete node; } else if( *info < *(p->getInfo()) ) p->setLeft( node ); else p->setRight( node ); } // end of insert http://ecomputernotes.com
  • 39. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 40. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 41. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 42. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 43. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 44. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 45. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 46. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p q http://ecomputernotes.com
  • 47. Trace of insert 17, 9, 14, 5 14 15 4 9 7 18 3 5 16 20 17 p p->setRight( node ); node http://ecomputernotes.com

Editor's Notes

  1. End of lecture 11
  2. End of lecture 12